package org.openharmony.qttool.components;

import javax.swing.*;
import java.awt.*;

public class QtProjectTypeSelector extends JPanel {

    public enum Type { Widget, Quick }
    private final JRadioButton widgetRadioButton;
    private final JRadioButton qmlRadioButton;

    public QtProjectTypeSelector(boolean widget) {
        widgetRadioButton = new JRadioButton("Qt Widget");
        add(widgetRadioButton);
    qmlRadioButton = new JRadioButton("Qt Quick2");
        add(qmlRadioButton);
        if (widget) {
            widgetRadioButton.setSelected(true);
        } else {
            qmlRadioButton.setSelected(true);
        }
        ButtonGroup g = new ButtonGroup();
        g.add(widgetRadioButton);
        g.add(qmlRadioButton);
        FlowLayout l = (FlowLayout) getLayout();
        if (l != null)
            l.setAlignment(FlowLayout.LEFT);
    }
    public Type getSelectedType() {
        if (widgetRadioButton.isSelected()) {
            return Type.Widget;
        } else if (qmlRadioButton.isSelected()) {
            return Type.Quick;
        }
        return Type.Widget;
    }
}




